import muBan from './myCanvas';

export default (myCanvas, height, weight) => {
	var color = '#007FFF';
	var color_ = "#000000"; 
  var font = '12px Arial';
  var font2 = '30px Microsoft YaHei';
  var a = [
    '2',
    '4',
    '6',
    '8',
    '10',
    '12',
    '14',
    '16',
    '18',
    '20',
    '22',
    '24',
    '26',
    '28',
    '30',
    '32',
    '34',
    '36月',
  ];
  var l = [
    '',
    '105',
    '100',
    '95',
    '90',
    '85',
    '80',
    '75',
    '70',
    '65',
    '60',
    '55',
    '50',
    '45',
    '4',
    '2',
  ];
  var r = [
    '',
    '105',
    '100',
    '95',
    '90',
    '85',
    '20',
    '18',
    '16',
    '14',
    '12',
    '10',
    '8',
    '6',
    '4',
    '2',
  ];
  var t = '身高(cm)';
  var b = '体重(kg)';
  var title = '中国0~3岁男童身高、体重百分位曲线图';
  var arr_h_3 = [
    [0, 47.1],
    [2, 54.6],
    [4, 60.3],
    [6, 64],
    [9, 67.9],
    [12, 71.5],
    [15, 74.4],
    [18, 76.9],
    [21, 79.5],
    [24, 82.1],
    [30, 86.4],
    [36, 89.7],
  ];
  var arr_h_10 = [
    [0, 48.1],
    [2, 55.9],
    [4, 61.7],
    [6, 65.4],
    [9, 69.4],
    [12, 73.1],
    [15, 76.1],
    [18, 78.7],
    [21, 81.4],
    [24, 84.1],
    [30, 88.6],
    [36, 91.9],
  ];
  var arr_h_25 = [
    [0, 49.2],
    [2, 57.2],
    [4, 63],
    [6, 66.8],
    [9, 70.9],
    [12, 74.7],
    [15, 77.8],
    [18, 80.6],
    [21, 83.4],
    [24, 86.2],
    [30, 90.8],
    [36, 94.2],
  ];
  var arr_h_50 = [
    [0, 50.4],
    [2, 58.7],
    [4, 64.6],
    [6, 68.4],
    [9, 72.6],
    [12, 76.5],
    [15, 79.8],
    [18, 82.7],
    [21, 85.6],
    [24, 88.5],
    [30, 93.3],
    [36, 96.8],
  ];
  var arr_h_75 = [
    [0, 51.6],
    [2, 60.3],
    [4, 66.2],
    [6, 70],
    [9, 74.4],
    [12, 78.4],
    [15, 81.8],
    [18, 84.8],
    [21, 87.9],
    [24, 90.9],
    [30, 95.9],
    [36, 99.4],
  ];
  var arr_h_90 = [
    [0, 52.7],
    [2, 61.7],
    [4, 67.6],
    [6, 71.5],
    [9, 75.9],
    [12, 80.1],
    [15, 83.6],
    [18, 86.7],
    [21, 90],
    [24, 93.1],
    [30, 98.2],
    [36, 101.8],
  ];
  var arr_h_97 = [
    [0, 53.8],
    [2, 63],
    [4, 69],
    [6, 73],
    [9, 77.5],
    [12, 81.8],
    [15, 85.4],
    [18, 88.7],
    [21, 92],
    [24, 95.3],
    [30, 100.5],
    [36, 104.1],
  ];

  var arr_w_3 = [
    [0, 2.62],
    [2, 4.53],
    [4, 5.99],
    [6, 6.8],
    [9, 7.56],
    [12, 8.16],
    [15, 8.68],
    [18, 9.19],
    [21, 9.71],
    [24, 10.22],
    [30, 11.11],
    [36, 11.94],
  ];
  var arr_w_10 = [
    [0, 2.83],
    [2, 4.88],
    [4, 6.43],
    [6, 7.28],
    [9, 8.09],
    [12, 8.72],
    [15, 9.27],
    [18, 9.81],
    [21, 10.37],
    [24, 10.9],
    [30, 11.85],
    [36, 12.74],
  ];
  var arr_w_25 = [
    [0, 3.06],
    [2, 5.25],
    [4, 6.9],
    [6, 7.8],
    [9, 8.66],
    [12, 9.33],
    [15, 9.91],
    [18, 10.48],
    [21, 11.08],
    [24, 11.65],
    [30, 12.66],
    [36, 13.61],
  ];
  var arr_w_50 = [
    [0, 3.32],
    [2, 5.68],
    [4, 7.45],
    [6, 8.41],
    [9, 9.33],
    [12, 10.05],
    [15, 10.68],
    [18, 11.29],
    [21, 11.93],
    [24, 12.54],
    [30, 13.64],
    [36, 14.65],
  ];
  var arr_w_75 = [
    [0, 3.59],
    [2, 6.15],
    [4, 8.04],
    [6, 9.07],
    [9, 10.06],
    [12, 10.83],
    [15, 11.51],
    [18, 12.16],
    [21, 12.86],
    [24, 13.51],
    [30, 14.7],
    [36, 15.8],
  ];
  var arr_w_90 = [
    [0, 3.85],
    [2, 6.59],
    [4, 8.61],
    [6, 9.7],
    [9, 10.75],
    [12, 11.58],
    [15, 12.3],
    [18, 13.01],
    [21, 13.75],
    [24, 14.46],
    [30, 15.73],
    [36, 16.92],
  ];
  var arr_w_97 = [
    [0, 4.12],
    [2, 7.05],
    [4, 9.2],
    [6, 10.37],
    [9, 11.49],
    [12, 12.37],
    [15, 13.15],
    [18, 13.9],
    [21, 14.7],
    [24, 15.46],
    [30, 16.83],
    [36, 18.12],
  ];

  var m = new muBan(35, 60, 100, 100);
  var c = document.getElementById(myCanvas);
  var ctx = c.getContext('2d');

  m.box(ctx, color, 0.75, 0.2, 19, 38, 17, 170); //画格子
  m.txt(ctx, color, font, a, a, l, r, t, b, 19, 17); //写字
  m.title(ctx, color, font2, title, 19);

  //身高
  m.line(ctx, 36, color, 2, arr_h_3, 13, 45, 5, 2, false, false, '3');
  m.line(ctx, 36, color, 0.5, arr_h_10, 13, 45, 5, 2, false, false, '10');
  m.line(ctx, 36, color, 0.5, arr_h_25, 13, 45, 5, 2, false, false, '25');
  m.line(ctx, 36, color, 2, arr_h_50, 13, 45, 5, 2, false, false, '50');
  m.line(ctx, 36, color, 0.5, arr_h_75, 13, 45, 5, 2, false, false, '75');
  m.line(ctx, 36, color, 0.5, arr_h_90, 13, 45, 5, 2, false, false, '90');
  m.line(ctx, 36, color, 2, arr_h_97, 13, 45, 5, 2, false, false, '97');

  //体重
  m.line(ctx, 36, color, 2, arr_w_3, 15, 2, 2, 2, false, false, '3');
  m.line(ctx, 36, color, 0.5, arr_w_10, 15, 2, 2, 2, false, false, '10');
  m.line(ctx, 36, color, 0.5, arr_w_25, 15, 2, 2, 2, false, false, '25');
  m.line(ctx, 36, color, 2, arr_w_50, 15, 2, 2, 2, false, false, '50');
  m.line(ctx, 36, color, 0.5, arr_w_75, 15, 2, 2, 2, false, false, '75');
  m.line(ctx, 36, color, 0.5, arr_w_90, 15, 2, 2, 2, false, false, '90');
	m.line(ctx, 36, color, 2, arr_w_97, 15, 2, 2, 2, false, false, '97');
	
	height && m.line(ctx, 36, color_, 2, height, 13, 45, 5, 2, true, false, null); //身高
  weight && m.line(ctx, 36, color_, 2, weight, 15, 2, 2, 2, true, false, null); //体重
};
